sockets: Fix IPv6 raw packet checksum in IPv6-only configuration #48
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue:
In an IPv6-only setup, raw IPv6 packets were being sent with an incorrect checksum, whereas they worked correctly in a dual-stack configuration (both IPv4 and IPv6).
Analysis:
raw.c
when thepcb->chksum_reqd
flag is set.api_msg.c
, but only whenNETCONNTYPE_ISIPV6(msg->conn->type)
evaluates to true.NETCONNTYPE_ISIPV6()
checks if theNETCONN_TYPE_IPV6
flag is set in the netconn type. This flag wasn’t being set when creating the socket, as theDOMAIN_TO_NETCONN_TYPE()
macro returned the original type without adding the IPv6 flag.Fix:
DOMAIN_TO_NETCONN_TYPE()
to set theNETCONN_TYPE_IPV6
flag.Alternative Approach:
enum netconn_type
to reflect both the connection type and protocol family (as of now) in a dual-stack setup, while reflect connection type only in a single-stack setup (IPv4 only or IPv6 only).(i.e. setting
NETCONNTYPE_ISIPV6()
totrue
in IPv6 only mode)PS: saw that you enabled CI runs for new PRs, so maybe you'll accept something from Github, too.
PPS: the main reason for choosing this way of fixing is that the alternative would require semantic changes to the API, but open to suggestions.